package com.ea.eadp.nexus.test.workflow.newconsole.login;

import com.ea.eadp.nexus.test.common.TestUtil;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;

import com.ea.eadp.nexus.test.common.SystemProperties;
import com.ea.eadp.nexus.test.workflow.WorkflowElement;
import com.ea.eadp.nexus.test.workflow.WorkflowElementArgument;

public class VerifyLoginCompleteWorkflowElement extends WorkflowElement {

    public VerifyLoginCompleteWorkflowElement(
        WebDriver driver, WorkflowElementArgument argument
    ) {
        super(driver, argument);
    }
    
    @Override
    public void doVerification() {
        try {
            Thread.sleep(5000);
        } catch (InterruptedException e) {}
        
        String url = TestUtil.getCurrentUrl(driver);
        log.info("Browser URL:" + url);
        String redirectURI =
            SystemProperties.instance().getProperty(SystemProperties.RedirectUri);
        Assert.assertTrue(
            url.contains(redirectURI) && url.contains("?code="),
            "Verify login complete failed."
        );
    }
    
}
